package com.clock.service.impl;

import cn.hutool.core.date.DateUtil;
import com.clock.domain.entity.NewLevel;
import com.clock.mapper.NewLevelMapper;
import com.clock.service.NewLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NewLevelServiceImpl implements NewLevelService {

    @Autowired
    private NewLevelMapper newLevelMapper;




    @Override
    public boolean insertNewLevel(NewLevel newLevel) {
         //1.参数判空
        if(newLevel != null){

            //设置关卡创建时间
            if(newLevel.getLevelCreateTime() == null){
                newLevel.setLevelCreateTime(DateUtil.date());
            }





            int insert = newLevelMapper.insert(newLevel);
            if(insert<=0){
                return false;
            }
        }
        return true;
    }


    /**
     * 删除关卡
     * @param id
     * @return
     */
    @Override
    public boolean deleteLevel(int id) {
        //1.判定参数
        if(id <= 0){
            return false;
        }
        int i = newLevelMapper.deleteById(id);
        if(i <= 0){
            return false;
        }
        return true;
    }


}
